package org.sun.dbrd.mains;

import java.io.File;

import org.dbrd.Config;
import org.sun.dbrd.IdsPreprocessor;
import org.sun.dbrd.IdsPreprocessor.VersionOrderMap;

public abstract class AbstractPreprocessorMain {

	public void run() {
		Config.IDENTIFYING_PROCESSING = true;

		File summaryFile = getSummaryFile();
		File resultFile = getResultFile();
		File mappingFile = getMappingFile();
		File versionOrderFile = getVersionOrderFile();
		createPreprocessor(summaryFile, resultFile, mappingFile, versionOrderFile);
		System.err.println("done!");
	}

	protected IdsPreprocessor createPreprocessor(File summaryFile, File resultFile, File mappingFile, File versionOrderFile) {
		return new IdsPreprocessor(summaryFile, resultFile, mappingFile, versionOrderFile) {
			@Override
			protected VersionOrderMap createVersionOrderMap(File versionOrderFile) {
				return AbstractPreprocessorMain.this.createVersionOrderMap(versionOrderFile);
			}
		};
	}

	protected VersionOrderMap createVersionOrderMap(File versionOrderFile) {
		return new VersionOrderMap(versionOrderFile);
	}

	abstract protected File getMappingFile();

	abstract protected File getResultFile();

	abstract protected File getSummaryFile();

	abstract protected File getVersionOrderFile();
}
